------------------------------------------------------------------------------------------------------------------------------------------------
      name:  <unnamed>
       log:  C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\figure2.log
  log type:  text
 opened on:  14 Jan 2019, 15:39:47

. #delimit ;
delimiter now ;
. *     ***************************************************************** *;
. *     ***************************************************************** *;
. *       File-Name:      figure2.do                                      *;
. *       Date:           January 14, 2019                                *;
. *       Author:         MRG/CC                                          *;
. *       Purpose:        Produce Figure 2 for It's Not Only What You     *;
. *                       Say, It's Also How You Say It: The Strategic    *;
. *                       Use Of Campaign Sentiment. Journal of Politics. *;
. *                       Forthcoming.                                    *;
. *           Input File:     sentiment.dta                                   *;
. *       Output File:    figure2.log                                     *;
. *       Data Output:    none                                            *;
.              *       Previous file:  sentiment.dta                                   *;
. *       Machine:        desktop/laptop                                                  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *        Load data                                                      *;
. *     ****************************************************************  *;
. use "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\sentiment.dta", clear;

. *     ****************************************************************  *;
. *       Declare data to be panel, where the panel is based on language  *;
. *     ****************************************************************  *;
. xtset language;
       panel variable:  language (unbalanced)

. xtsum positive_sentiment;

Variable         |      Mean   Std. Dev.       Min        Max |    Observations
-----------------+--------------------------------------------+----------------
positi~t overall |  1.696912   1.446166       -.68        7.6 |     N =     421
         between |              1.34797   .4018627     4.3828 |     n =       7
         within  |             .7198334  -1.565888   4.914112 | T-bar = 60.1429

. *     ****************************************************************  *;
. *       Generate additional variables that we will need for our         *;
. *       analysis.                                                       *;
. *     ****************************************************************  *;
. gen incumbent_inflation_l = incumbent*inflation_l;
(21 missing values generated)

. label var incumbent_inflation "incumbent*inflation_l";

. gen incumbent_unemployment_l = incumbent*unemployment_l;
(7 missing values generated)

. label var incumbent_unemployment_l "incumbent*unemployment_l";

. gen incumbent_pm = incumbent*pm;

. label var incumbent_pm "incumbent*pm";

. gen incumbent_fm = incumbent*fm;

. label var incumbent_fm "incumbent*fm";

. gen left_right2=left_right*left_right;
(39 missing values generated)

. label var left_right2 "left_right*left_right";

. gen extremist = 0;

. replace extremist=1 if family_id ==14 | family_id==40;
(87 real changes made)

. replace extremist = . if family_id==.;
(9 real changes made, 9 to missing)

. label var extremist "1 if communist/socialist or far right, 0 otherwise";

. gen extremist2 = 0;

. replace extremist2=1 if family_id ==14 | family_id==40 | family_id==19;
(124 real changes made)

. replace extremist2 = . if family_id==.;
(9 real changes made, 9 to missing)

. label var extremist2 "1 if communist/socialist, far right, or greens, 0 otherwise";

. gen extremist_inflation_l=extremist*inflation_l;
(30 missing values generated)

. label var extremist_inflation "extremist*inflation_l";

. gen extremist_unemployment_l=extremist*unemployment_l;
(16 missing values generated)

. label var extremist_unemployment_l "extremist*unemployment_l";

. tabulate language, gen(l);

   language |      Freq.     Percent        Cum.
------------+-----------------------------------
      Dutch |        102       24.23       24.23
    English |         85       20.19       44.42
     French |         36        8.55       52.97
     German |         46       10.93       63.90
    Italian |         54       12.83       76.72
 Portuguese |         50       11.88       88.60
    Spanish |         48       11.40      100.00
------------+-----------------------------------
      Total |        421      100.00

. *     ****************************************************************  *;
. *      Change graph scheme                                                  *;
. *     ****************************************************************  *;
. ssc install scheme-burd, replace;
checking scheme-burd consistency and verifying not already installed...
all files already exist and are up to date.

. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *       Produce Figure 2                                                *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *     ****************************************************************  *;
. *       Panel A                                                         *;
. *     ****************************************************************  *;
. graph box positive_emotion, over(language) ytitle("Positive Words Score") scheme(burd);

. graph export "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig2a.pdf", replace;
(file C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig2a.pdf written in PDF format)

. *     ****************************************************************  *;
. *       Panel B                                                         *;
. *     ****************************************************************  *;
. graph box negative_emotion, over(language) ytitle("Negative Words Score") scheme(burd);

. graph export "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig2b.pdf", replace;
(file C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig2b.pdf written in PDF format)

. *     ****************************************************************  *;
. *       Panel C                                                         *;
. *     ****************************************************************  *;
. graph box positive_sentiment, over(language) ytitle("Positive Sentiment") scheme(burd);

. graph export "C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig2c.pdf", replace;
(file C:\Users\mgolder\Dropbox\campaign_sentiment_paper\fig2c.pdf written in PDF format)

. *     ****************************************************************  *;
. *       Replication complete                                            *;
. *     ****************************************************************  *;
. log close;
      name:  <unnamed>
       log:  C:\Users\mgolder\Dropbox\campaign_sentiment_paper\replication\data_analysis\figure2.log
  log type:  text
 closed on:  14 Jan 2019, 15:39:53
------------------------------------------------------------------------------------------------------------------------------------------------
